

import request from '@/router/axios'

const prefix = '/rca/swckelectronicreceipt'

export function fetchList(query) {
  return request({
    url: prefix+'/page',
    method: 'get',
    params: query
  })
}

export function dataExport(obj) {
  return request({
    url: prefix+'/exportExcel',
    method: 'post',
    responseType: 'blob',
    data: obj
  })
}

export function confirm(obj) {
  return request({
    url: prefix+'/confirmStatus',
    method: 'post',
    data: obj
  })
}

export function getObj(id) {
  return request({
    url: prefix+'/' + id,
    method: 'get'
  })
}

export function putObj(obj) {
  return request({
    url: prefix,
    method: 'put',
    data: obj
  })
}

const uploadPrefix = '/rca/swckelectronicreceipttmp'
export const tables = {

  // 查询指定表数据
  listPreview: (query)=>{
    return request({
      url: `${uploadPrefix}/list`,
      method: 'get',
      params: query
    })
  },
  // 下载模板
  template: (query)=>{
    return request({
      url: `${uploadPrefix}/exportTamplate`,
      method: 'get',
      responseType: 'blob',
      params: query
    })
  },
  saveBatch: (query)=>{
    return request({
      url: `${uploadPrefix}/saveBatch`,
      method: 'post',
      headers: {
        'Content-Type': 'multipart/form-data'
      },
      data: query,
      timeout: 3600000
    })
  },
  saveBatchOk: (query)=>{
    return request({
      url: `${uploadPrefix}/saveBatchOk`,
      method: 'post',
      data: query
    })
  },
  saveBatchCancel: (query)=>{
    return request({
      url: `${uploadPrefix}/saveBatchCancel`,
      method: 'post',
      data: query
    })
  },
}
